{template "header.html", "/"}

<div class="page-container">
    <div class="page-content-wrapper">

        <div class="page-content">
            <div class="container">

                <ul class="page-breadcrumb breadcrumb">
                    <li><a href="{SITE_URL}">首页</a><i class="fa fa-angle-right"></i></li>
                    {if defined('IS_SHARE') && !IS_SHARE}
                    <li><a href="{MODULE_URL}">{MODULE_NAME}</a><i class="fa fa-angle-right"></i></li>
                    {/if}
                    {dr_catpos($catid, '', 1, '<li><a href="{url}">{name}</a><i class="fa fa-angle-right"></i></li>'.PHP_EOL)}
                    <li> <span>商品</span></li>
                </ul>

                <div class="news-content row">

                    <div class="col-md-4">

                        <div class="preview">
                            <div id="vertical" class="bigImg">
                                <img src="{dr_get_file($thumb[0])}" height="300" alt="" id="midimg" />
                                <div style="display:none;" id="winSelector"></div>
                            </div><!--bigImg end-->
                            <div class="smallImg">
                                <div class="scrollbutton smallImgUp disabled"></div>
                                <div id="imageMenu">
                                    <ul>
                                        {loop $thumb $i $pic}
                                        <li {if $i==0}id="onlickImg"{/if}><img src="{dr_thumb($pic, 68, 68)}" max-src="{dr_get_file($pic)}" width="68" height="68" /></li>
                                        {/loop}
                                    </ul>
                                </div>
                                <div class="scrollbutton smallImgDown"></div>
                            </div><!--smallImg end-->
                            <div id="bigView" style="display:none;"><img width="800" height="800" alt="" src="" /></div>
                        </div>

                        <script src="{HOME_THEME_PATH}pc/scripts/shop.js" type="text/javascript"></script>

                    </div>
                    <div class="col-md-6">
                        <div class="product_info">
                            <h1>
                                {$title}
                                {if !$order_shipping}<span class="ico s_mianyuyue display1">包邮</span>{/if}
                                {if !$order_status}<span class="ico s_tuijian display1">已下架</span>{/if}
                            </h1>
                            <ul class="price clearfix">
                                <li class="list_1"><span class="tit">商城价</span>￥<em id="dr_sku_price">{$order_price}</em></li>
                                <li class="list_2"><span class="tit">商品编码</span><span class="dels" id="dr_sku_sn">{$order_sn}</span></li>
                                <li class="list_3"><span class="tit">所在地</span><span class="dels">{dr_linkagepos('address', $order_city, ' » ')}</span></li>
                                <li class="mobilread">手机下单<img src="{dr_qrcode_url(SITE_MURL.dr_mobile_show_url(MOD_DIR, $id))}" id="mobilread" alt="手机访问"></li>
                            </ul>
                            <ul class="tabe clearfix">
                                <li id="tgDetail">已售出 <span class="tg_chrnum tg_chrnum_4">{$order_volume}</span></li>
                                <li class="b">累计评价 <span id="show_total_revert1">{$comments}</span></li>
                                <li>人气指数 <span>{dr_show_hits($id)}</span></li>
                            </ul>

                            <div class="i_buy" id="i_buy">
                                {if $order_specification}
                                {php $sku = dr_get_spec_data($catid, $order_specification);}
                                {loop $sku $oname $s}
                                {if isset($order_specification['option'][$oname]) && $order_specification['option'][$oname]}
                                <div class="attributes">
                                    <div class="attribute-label">{$s['name']}：</div>
                                    <div class="attribute-list carbox">
                                        <input class="dr_sku_value" id="dr_sku_{$oname}" oname="{$oname}" type="hidden" value="" />
                                        <div class="dr_sku_{$oname} sku-value">
                                            {loop $order_specification['option'][$oname] $val}
                                            <span {if $sku[$oname]['type']=='color'} style="background-color:{php echo preg_match('/[a-z]+/', $val) ? $val : '#'.$val;}"{/if} id="dr_sku_value_{$val}" ovalue="{$val}" class="txt" onclick="dr_sku_select_item(this, '{$oname}', '{$val}')" title="{$s['value'][$val]}"><b></b>{if $sku[$oname]['type']=='color'}&nbsp;{else}{$s['value'][$val]}{/if}</span>
                                            {/loop}
                                        </div>
                                    </div>
                                </div>
                                {/if}
                                {/loop}
                                {/if}
                                <div class="sel">
                                    <span class="a">选择数量：</span>
                                    <span class="b">
									<div class="num clearfix" id="buyNumC">
										<a href="javascript:;" class="reduce"  onclick="dr_sku_item_num(0)">-</a>
										<input type="text" class="num_ipt" id="dr_sku_num" value="1" name="num">
										<a href="javascript:;" class="increase"  onclick="dr_sku_item_num(1)">+</a>
										<div class="knum display0">库存 <em id="dr_sku_quantity">{$order_quantity}</em> 件</div>
									</div>
								</span>
                                </div>
                                <div class="btn3 clearfix" id="buyBtn">
                                    <a href="javascript:;" class="buyto" id="buyto" onclick="dr_buy()">立即购买</a>
                                    <a href="javascript:;" class="addto" id="addto" ii="{dr_get_file($thumb[0])}" href="javascript:;" onclick="dr_cart()">添加购物车</a>
                                    <a href="javascript:;" class="buyto2" id="buyto2" onclick="dr_module_favorite('{MOD_DIR}', '{$id}', 0)">加入收藏</a>
                                </div>
                                <script language="javascript">



                                    {php $sku_sn = $sku_price = $sku_quantity = array();}
                                    {loop $order_specification.value $iid $t}
                                    {php $sku_price[$iid] = $t['price'];}
                                    {php $sku_sn[$iid] = $t['sn'];}
                                    {php $sku_quantity[$iid] = $t['quantity'];}
                                    {/loop}
                                    var sku_sn = {json_encode($sku_sn)};
                                    var sku_price = {json_encode($sku_price)};
                                    var sku_quantity = {json_encode($sku_quantity)};

                                    // 商品数量加减选择
                                    function dr_sku_item_num(op) {
                                        var num = parseInt($("#dr_sku_num").val());
                                        var _quantity = parseInt($("#dr_sku_quantity").html());
                                        if (isNaN(num) || num <= 1) num = 1;
                                        if (op) {
                                            // 加操作
                                            num++;
                                            if (num >= _quantity) num = _quantity;
                                        } else {
                                            // 减操作
                                            num--;
                                            if (isNaN(num) || num <= 1) num = 1;
                                        }
                                        $("#dr_sku_num").val(num);
                                    }
                                    // 购买商品
                                    function dr_buy() {
                                        {if !$member}
                                        dr_login();
                                        return;
                                        {/if}
                                        var order = "{dr_url('order/home/index', array('mid'=>MOD_DIR, 'cid'=>$id))}";
                                        {if $order_specification}
                                        var i = 0;
                                        var sku = new Array();
                                        $(".dr_sku_value").each(function(){
                                            var id = $(this).val();
                                            if (id == "") {
                                                // 请勾选您要的商品信息
                                                dr_tips("请勾选您要的商品信息", 3);
                                                return;
                                            }
                                            sku[i] = id;
                                            i++;
                                        });
                                        order+= "&spec="+sku.join("_"); // 组合串联属性
                                        {/if}
                                        // 判断库存
                                        var _quantity = parseInt($("#dr_sku_quantity").html());
                                        if (isNaN(_quantity) || _quantity <= 0) {
                                            dr_tips("库存不足无法购买", 3);
                                            return;
                                        }
                                        var num = parseInt($("#dr_sku_num").val());
                                        order+= "&num="+num;
                                        location.href=order;
                                    }
                                    // 购物车
                                    var is_cart = true;
                                    function dr_cart() {
                                        if (!is_cart) {
                                            //alert('刷新后再试');
                                            //return;
                                        }
                                        var cart = "{dr_url('order/cart/add', array('mid'=>MOD_DIR, 'cid'=>$id))}";
                                        {if $order_specification}
                                        var i = 0;
                                        var sku = new Array();
                                        $(".dr_sku_value").each(function(){
                                            var id = $(this).val();
                                            if (id == "") {
                                                // 请勾选您要的商品信息
                                                dr_tips("请勾选您要的商品信息", 3);
                                                return;
                                            }
                                            sku[i] = id;
                                            i++;
                                        });
                                        cart+= "&spec="+sku.join("_");
                                        {/if}
                                        // 判断库存
                                        var _quantity = parseInt($("#dr_sku_quantity").html());
                                        if (isNaN(_quantity) || _quantity <= 0) {
                                            dr_tips("库存不足无法购买", 3);
                                            return;
                                        }
                                        var num = parseInt($("#dr_sku_num").val());
                                        cart+= "&num="+num;
                                        is_cart = false;
                                        $.ajax({type: "GET", url: cart, dataType:"jsonp",
                                            success: function (data) {
                                                if (data.status) {
                                                    $("#shop_cart_num").html(data.code);
                                                    dr_tips('添加成功，购车中共'+data.code+'件商品', 3, 1);
                                                } else {
                                                    dr_tips(data.code);
                                                    is_cart = true;
                                                }
                                            }
                                        });
                                    }
                                    // 按规则更新商品价格
                                    function dr_sku_update_item() {
                                        var i = 0;
                                        var sku = new Array();
                                        // 遍历属性
                                        $(".dr_sku_value").each(function(){
                                            var id = $(this).val();
                                            if (id == "") return;
                                            sku[i] = id;
                                            i++;
                                        });
                                        var oname = sku.join("_"); // 组合串联属性
                                        // 当全部勾选之后才更新商品价格与库存
                                        var _sn = sku_sn[oname];
                                        var _price = sku_price[oname];
                                        var _quantity = sku_quantity[oname];
                                        $("#dr_sku_price").html(price_float(_price));
                                        $("#dr_sku_sn").html(_sn);
                                        if (_quantity) {
                                            $("#dr_sku_quantity").html(_quantity);
                                        } else {
                                            $("#dr_sku_quantity").html("<font color=red>库存不足</font>");
                                        }
                                    }
                                    // 按规则选择商品
                                    function dr_sku_select_item(_this, oname, val) {
                                        $(".dr_sku_"+oname+" > span").attr("class", "txt");
                                        $(_this).attr("class", "curr");
                                        $("#dr_sku_"+oname).val(val);
                                        dr_sku_update_item();
                                    }
                                    function price_float(value){  //保留两位小数点
                                        if (!value) value = 0;
                                        value = Math.round(parseFloat(value) * 100) / 100;
                                        if (value.toString().indexOf(".") < 0) {
                                            value = value.toString() + ".00";
                                        }
                                        return value;
                                    }
                                    // 设置商品的默认规则
                                    $(function(){
                                        $(".dr_sku_value").each(function(){
                                            var id = $(this).val();
                                            var oname = $(this).attr("oname");
                                            $(".dr_sku_"+oname+" > span").attr("class", "txt");
                                            if (id) {
                                                $("#dr_sku_value_"+id).attr("class", "curr");
                                            } else {
                                                var _first = $(".dr_sku_"+oname+" span").first();
                                                var _iid = _first.attr("ovalue");
                                                _first.attr("class", "curr");
                                                $("#dr_sku_"+oname).val(_iid);
                                            }
                                            dr_sku_update_item();
                                        });
                                    });



                                </script>
                            </div>


                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="store_info">
                            <div class="hd">商家信息</div>
                            <div class="bd">
                                <span class="shop_title">{$author}</span>
                                <p class="line"><span class="a">上架时间：</span><span class="b">{$updatetime}</span></p>
                                <p class="commitment_hd">卖家承诺</p>
                                <ul class="commitment_bd" id="goodservice">
                                    <li class="display0"><span class="sp">1</span>2小时内送达;</li>
                                    <li class="display1"><span class="sp">1</span>免费配送;</li>
                                    <li class="display1"><span class="sp">2</span>如实描述;</li>
                                    <li class="display1"><span class="sp">3</span>7天无理由退换货;</li>
                                    <li class="display1"><span class="sp">4</span>假一赔三;</li>
                                    <li class="display0"><span class="sp">6</span>同城最低价;</li>
                                    <li class="display1"><span class="sp">7</span>当天发货;</li>
                                    <li class="display0"><span class="sp">8</span>实体店服务支持;</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="news-content row">

                    <div class="col-md-12">


                        <div class="book-content margin-top-30">
                            <div class="commonTitle clearfix">
                                <h4 class="fl fw">商品属性</h4>
                            </div>
                            <div class="book-content-list ">
                                {php $sx = dr_mall_property_value($catid, $shangpinshuxing);}
                                <table cellpadding="0" cellspacing="1" width="100%" border="0" class="table table-bordered">
                                    <tbody>
                                    {loop $sx $name $value}
                                    <tr>
                                        <th class="tdTitle" colspan="2">{$name}</th>
                                    </tr>
                                    {loop $value $n $v}
                                    <tr>
                                        <td width="200" class="tdTitle">{$n}</td>
                                        <td>
                                            {if is_array($v)}
                                            {implode(' ', $v)}
                                            {else}
                                            {$v}
                                            {/if}
                                        </td>
                                    </tr>
                                    {/loop}
                                    {/loop}
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="book-content margin-top-30">
                            <div class="commonTitle clearfix">
                                <h4 class="fl fw">商品详情</h4>
                            </div>
                            <div class="book-content-list ">

                                {$content}

                            </div>
                        </div>

                        <div class="book-content margin-top-30">
                            <div class="commonTitle clearfix">
                                <h4 class="fl fw">网友评论</h4>
                            </div>
                            <div class="book-content-list ">

                                {dr_module_comment(MOD_DIR, $id)}

                            </div>
                        </div>

                    </div>



                </div>

            </div>
        </div>

    </div>

</div>


{template "shop.html"}
{template "footer.html", "/"}